package com.acceptable.qucun.generic.util.result.success;

import java.util.HashMap;
import java.util.Map;

public enum  FileSuccessResult implements BaseSuccessResult{
    // 首位为1 代表成功 次位为1 文件相关 6位

    CHUNK_UPLOAD_SUCCESS("110100", "当前文件块上传成功。"),
    MANUAL_STOP_UPLOAD_SUCCESS("110110", "取消当前文件上传成功"),
    REST_VOLUME_SUCCESS("110200", "剩余容量足够。"),
    MERGE_SUCCESS("110300", "文件合并成功"),
    INFO_SELECT_SUCCESS("110400", "该文件信息查询成功。"),
    ENTER_DICT_SUCCESS("110500", "成功进入该文件夹"),
    EXIST_SUCCESS("110600", "该文件存在完整数据，且已经合并。"),
    PART_EXIST_SUCCESS("110650", "该文件存在部分数据，请上传剩余数据"),
    NOT_EXIST_SUCCESS("110700", "文件不存在。"),
    CREATE_DICT_SUCCESS("110800", "成功创建文件夹。"),
    RENAME_SUCCESS("110900", "文件（夹）重命名成功。"),
    LOGICAL_DELETE_SUCCESS("111000", "文件删除成功，回收站中保留7天。"),
    SUB_DICT_INFO_SUCCESS("111100", "该目录下的子目录查询成功。"),
    MOVE_SUCCESS("111200", "当前选中的文件成功移动至别处。"),
    COPY_SUCCESS("111300", "当前选中的文件成功复制至别处。"),

    ALL_EXIST_SUCCESS("111400","欲下载文件物理上均存在。" ),
    NOT_ALL_EXIST_SUCCESS("111500", "欲下载文件物理上存在一部分"),
    DOWNLOAD_SUCCESS("111600", "文件下载成功"),
    FILTER_CATEGORY_SUCCESS("111700", "文件类型筛选成功。"),
    LOGICAL_RECOVERY_SUCCESS("111800", "被选中的回收站文件还原成功。"),
    PHYSICAL_DELETE_SUCCESS("111900", "物理删除文件成功。"),

    // 分享相关
    SHARE_CREATE_LINK_SUCCESS("112000", "成功创建分享链接。"),
    SHARE_EXIST_SUCCESS("112100", "该分享链接有效。"),
    SHARE_FILE_LIST_SUCCESS("112200", "成功获取该链接相关的文件。"),
    SHARE_INFO_LIST_SUCCESS("112300", "成功获取所有的分享信息。"),
    SHARE_UPDATE_SUCCESS("112400", "分享信息修改成功"),
    SHARE_CANCEL_SUCCESS("112500", "该分享链接取消成功。");

    private String code;
    private String msg;
    FileSuccessResult(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    private static Map<String, FileSuccessResult> resultMap;

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMsg() {
        return msg;
    }

    private static void createMap(){
        if(resultMap == null){
            resultMap = new HashMap<>();
        }

        // 上传
        {
            resultMap.put(CHUNK_UPLOAD_SUCCESS.code, CHUNK_UPLOAD_SUCCESS);
            resultMap.put(MANUAL_STOP_UPLOAD_SUCCESS.code, MANUAL_STOP_UPLOAD_SUCCESS);
            resultMap.put(REST_VOLUME_SUCCESS.code, REST_VOLUME_SUCCESS);
            resultMap.put(MERGE_SUCCESS.code, MERGE_SUCCESS);
            resultMap.put(EXIST_SUCCESS.code, EXIST_SUCCESS);
            resultMap.put(PART_EXIST_SUCCESS.code, PART_EXIST_SUCCESS);
        }

        // 文件详情查询
        resultMap.put(INFO_SELECT_SUCCESS.code, INFO_SELECT_SUCCESS);
        resultMap.put(NOT_EXIST_SUCCESS.code, NOT_EXIST_SUCCESS);
        resultMap.put(FILTER_CATEGORY_SUCCESS.code, FILTER_CATEGORY_SUCCESS);

        // 文件夹
        resultMap.put(ENTER_DICT_SUCCESS.code, ENTER_DICT_SUCCESS);
        resultMap.put(CREATE_DICT_SUCCESS.code, CREATE_DICT_SUCCESS);

        resultMap.put(RENAME_SUCCESS.code, RENAME_SUCCESS);
        resultMap.put(LOGICAL_DELETE_SUCCESS.code, LOGICAL_DELETE_SUCCESS);
        resultMap.put(SUB_DICT_INFO_SUCCESS.code, SUB_DICT_INFO_SUCCESS);
        resultMap.put(COPY_SUCCESS.code, COPY_SUCCESS);
        resultMap.put(MOVE_SUCCESS.code, COPY_SUCCESS);

        resultMap.put(ALL_EXIST_SUCCESS.code, ALL_EXIST_SUCCESS);
        resultMap.put(NOT_ALL_EXIST_SUCCESS.code, NOT_ALL_EXIST_SUCCESS);
        resultMap.put(DOWNLOAD_SUCCESS.code, DOWNLOAD_SUCCESS);
        resultMap.put(LOGICAL_RECOVERY_SUCCESS.code, LOGICAL_RECOVERY_SUCCESS);
        resultMap.put(PHYSICAL_DELETE_SUCCESS.code, PHYSICAL_DELETE_SUCCESS);

        // 文件分享
        {
            resultMap.put(SHARE_FILE_LIST_SUCCESS.code, SHARE_FILE_LIST_SUCCESS);
            resultMap.put(SHARE_EXIST_SUCCESS.code, SHARE_EXIST_SUCCESS);
            resultMap.put(SHARE_INFO_LIST_SUCCESS.code, SHARE_INFO_LIST_SUCCESS);
            resultMap.put(SHARE_UPDATE_SUCCESS.code, SHARE_UPDATE_SUCCESS);
            resultMap.put(SHARE_CANCEL_SUCCESS.code, SHARE_CANCEL_SUCCESS);
        }
    }

    public static BaseSuccessResult getSuccessResultByCode(String code){
        createMap();
        return resultMap.get(code);
    }

    public static Map<String, FileSuccessResult> getResultMap(){
        createMap();
        return resultMap;
    }
}
